﻿using UnityEngine;
using FT.Tweening;
using Vector3 = UnityEngine.Vector3;

namespace Game.WeaponComponent
{
    /// <summary>
    /// 基础近战攻击
    /// </summary>

    public class NormalMeleeAttackComponent :  ABSWeaponComponent {
        private Weapon mCurWeapon;
        //伤害
        public int Damage
        {
            get;
            set;
        }

        //速度
        public int Speed
        {
            get;
            set;
        } 
        
        public NormalMeleeAttackComponent(ABSWeaponCombinant combinant) : base(combinant) {
            if (combinant is Weapon) {
                mCurWeapon = combinant as Weapon;   
            }
            Speed = 10;
        }

        protected override void onTrigger()
        {
            mCurWeapon?.GameInstance.transform.DOLocalRotate(Vector3.forward * 90, GameConfig.NormalMeleeAttackConfig.AttackInterval).SetLoops(2, LoopType.Yoyo)
                .OnComplete(() => {
                    mCurWeapon.GameInstance.transform.localRotation = Quaternion.identity;
                    mCurWeapon.TriggerCount();
                });
        }
        
    }
}